home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / EX3_4.C < prev    next >
C/C++ Source or Header  |  1992-08-20  |  1KB  |  29 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12.  
  13. #include <cool/Random.h>            // Include Random number class
  14. #include <iostream.h>
  15.  
  16. int main (void) {
  17.  
  18.   CoolRandom r1 (SIMPLE, 1, 3.0, 9.0);        // Simple rand() generator
  19.   CoolRandom r2 (THREE_CONGRUENTIAL, 1, 5.0, 11.5);    // Highly random generator
  20.  
  21.   cout << "Simple random number generator:\n";    // Output banner title 
  22.   for (int i = 0; i < 10; i++)            // Generate 10 random numbers
  23.     cout << "  Random number " << i << " is: " << r1.next () << "\n";
  24.   cout << "\nThree congruential linear random number generator:\n"; // Banner
  25.   for (i = 0; i < 10; i++)            // Generate 10 random numbers
  26.     cout << "  Random number " << i << " is: " << r2.next () << "\n";
  27.   return (0);                    // Exit with OK status
  28. }
  29.